/*
 * \brief  DDE Linux 2.6 initialization
 * \author Björn Döbel
 * \author Christian Helmuth
 * \date   2008-11-11
 */

#include <dde_linux26/general.h>
#include <dde_kit/dde_kit.h>

#include "local.h"

/* Didn't know where to put this. */
unsigned long __per_cpu_offset[NR_CPUS];

extern void driver_init(void);
//extern int classes_init(void);

static void _main_thread_startup(void *fun)
{
	void(*main_thread)(void) = fun;

	dde_linux26_process_add_worker();

	/* Init Linux driver framework before trying to add PCI devs to the bus */
	driver_init();

	/* enter DDE main */
	main_thread();
}

void dde_linux26_init(void(*main_thread)(void))
{
	/* first, initialize DDE kit */
	dde_kit_init();

	/* second, initialize DDE Linux 2.6 subsystems */
	dde_linux26_printk_init();
	dde_linux26_kmalloc_init();
	dde_linux26_process_init();
	dde_linux26_timer_init();
	dde_linux26_softirq_init();

	/* finally, spawn main thread and return */
	dde_kit_thread_create(_main_thread_startup, main_thread, "DDE main");
}
